#version 460
#extension GL_GOOGLE_include_directive : enable

//#include "../../../../core/shader_widget_color.h"
#include "../../../../core/shader_color.h"
#include "../../../../core/shader_noise.h"


layout(location = 0) in vec2 gCoords;
layout(location = 1) in flat uint gInstanceIndex;

layout(location=0) out vec4 outColor;


//layout(std140, binding = DEF_BINDING_WIDGET_TexProp) uniform _TextueProp {
//	S_TextueProp TextueProp;
//};
layout(std430, column_major, binding = DEF_BINDING_WIDGET_TexProp) readonly buffer _TextueProp {
	S_TextueProp TextueProp[];
};

//layout(binding = DEF_BINDING_WIDGET_Texture) uniform sampler2D tex;

vec3 color_W = vec3(0.2125, 0.7154, 0.0721);

void main(void){
	//outColor = texture(tex, gCoords * TextueProp.m_TexCoordScale + TextueProp.m_TexCoordOffset);
	vec2 coord = gCoords;
	//coord.y += coord.x;

	outColor.r = f_glsl_simplexNoise(coord * TextueProp[gInstanceIndex].m_TexCoordScale + TextueProp[gInstanceIndex].m_TexCoordOffset);
	//outColor.r = 0.5;
	//outColor.g = f_glsl_simplexNoise(coord * TextueProp.m_TexCoordScale + TextueProp.m_TexCoordOffset + 1);
	//outColor.b = f_glsl_simplexNoise(coord * TextueProp.m_TexCoordScale + TextueProp.m_TexCoordOffset + 2);

	outColor.gb = vec2(outColor.r);
	//outColor.rgb = f_perlin2DNoise(coord * TextueProp.m_TexCoordScale + TextueProp.m_TexCoordOffset + 2, true);

	//outColor.r = random(gCoords.x);
	//outColor.g = random(gCoords.y);
	//outColor.b = 0;
	outColor.rgb *= TextueProp[gInstanceIndex].m_Intensity;
	outColor.a = 1;
	switch(TextueProp[gInstanceIndex].m_TexColorMode){
		case 1:
		//outColor.rgb =dot(outColor.rgb, color_W);
		break;

		case 2:
		break;

		default:
		break;
	}
	//vec4 vColor = f_glsl_buildColor(InstanceColor[gInstanceIndex]);
	//outColor *= vColor;
	//outColor = vec4(gCoords,1,1);
	//outColor = vec4(TextueProp[gInstanceIndex].m_TexCoordScale,1,1);
}





